//package com.utils.failureanalysis.data.dao;
//
//import com.utils.failureanalysis.data.model.singleModule.CountRecorder;
//import com.utils.failureanalysis.data.model.singleRecorder.Recorder;
//import org.springframework.context.annotation.Scope;
//
//import java.io.*;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Scope("session")
//public class AnalysisDataDao {
//    static final String savedPath = "D://FailureAnalysis_AnalysisData.txt";
//    File savedFile = new File(savedPath);
//    ObjectOutputStream oos;
//    ObjectInputStream ois;
//
//    //    历史分析数据
//
//    public AnalysisDataDao() throws IOException, ClassNotFoundException {
//        if (!savedFile.exists()) {
//            savedFile.createNewFile();
//            updateTestIdDateModel();
//        }
////        initData();
//        if (analysisData.getTaskAnalysisDataModelMap().isEmpty()) {
//            checkoutTestIdDateModel();
//        }
//    }
//
//    public void updateTestIdDateModel() throws IOException {
//        System.out.println("updateTestIdDateModel");
////        List<AnalysisRecord> analysisRecords = testIdDateModel.get("991").get("BatteryModule").getAnalysisRecord();
////        if (analysisRecords == null) System.out.println("analysisRecords is null");
//        write(analysisData);
//    }
//
//    public AnalysisData checkoutTestIdDateModel() throws IOException, ClassNotFoundException {
//        System.out.println("checkoutTestIdDateModel");
//        analysisData =  read();
//        return analysisData;
//    }
//
//    public void write(AnalysisData analysisData) throws IOException {
//        try {
//            oos = new ObjectOutputStream(new FileOutputStream(savedFile));
//            oos.writeObject(analysisData);
//        } finally {
//            if (oos != null) oos.close();
//        }
//    }
//
//    public AnalysisData read() throws IOException, ClassNotFoundException {
//        try {
//            ois = new ObjectInputStream(new FileInputStream(savedFile));
////            ois = new ObjectInputStream(new FileInputStream(savedFile));
//            AnalysisData analysisData = (AnalysisData) ois.readObject();
//            return analysisData;
//        } finally {
//            if (ois != null) ois.close();
//        }
//    }
//
//    public void initData() throws IOException {
//        System.out.println("initData");
//        CountRecorder countResult = new CountRecorder("BatteryModule", "13", "3");
//        CountRecorder countResult1 = new CountRecorder("Bluetooth", "13", "3");
//        Recorder recorder = new Recorder("BatteryModule", "20180707", "testBatteryOn", "fail", "failBecause...", "nullPointException");
//        Recorder recorder1 = new Recorder("BatteryModule", "20180707", "testBatteryOff", "fail", "failBecause...", "nullPointException");
//        Recorder recorder2 = new Recorder("Bluetooth", "201800000", "testBatteryOn", "fail", "failBecause...", "nullPointException");
//        Recorder recorder3 = new Recorder("Bluetooth", "201800000", "testBatteryOff", "fail", "failBecause...", "nullPointException");
//        HashMap<String, ModuleDataModel> h = new HashMap();
//        List<Recorder> recorderL = new ArrayList<>();
//        List<Recorder> recorderL1 = new ArrayList<>();
//        recorderL.add(recorder);
//        recorderL.add(recorder1);
//        recorderL1.add(recorder2);
//        recorderL1.add(recorder3);
//        ModuleDataModel moduleDataModel=new ModuleDataModel("BatteryModule",countResult,recorderL);
//        ModuleDataModel moduleDataMode2=new ModuleDataModel("Bluetooth",countResult1,recorderL1);
//        h.put("BatteryModule",moduleDataModel);
//        h.put("Bluetooth",moduleDataMode2);
//        SingleTaskAnalysisDataModel singleTaskAnalysisDataModel=new SingleTaskAnalysisDataModel("991",h);
//        Map<String,SingleTaskAnalysisDataModel> mSingleTaskAnalysisDataModel=new HashMap<>();
//        mSingleTaskAnalysisDataModel.put("991",singleTaskAnalysisDataModel);
//        analysisData=new AnalysisData(mSingleTaskAnalysisDataModel);
//        updateTestIdDateModel();
//    }
//
//}
